package service.impl;

import dao.UserDao;
import domain.EntityPerson;
import domain.VirtualFile;
import domain.VirtualUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import service.UserService;

import java.util.ArrayList;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public String getPsword(String username) {
        return userDao.getPsword(username);
    }

    @Override
    public boolean haveUser(String username) {
        return userDao.haveUser(username)!=null;
    }

    @Override
    public boolean haveEmail(String email) {
        return userDao.haveEmail(email)!=null;
    }

    @Override
    public void addUser(VirtualUser virtualUser) {
        userDao.addUser(virtualUser);
    }

    @Override
    public VirtualUser getByname(String username) {
    		// test
	    return userDao.getByname(username);
    }

    @Override
    public VirtualUser getByuid(int uid) {
        return userDao.getByuid(uid);
    }

    @Override
    public void resetUserInfo(int uid, String uname, String email) {
        userDao.resetUserInfo(uid,uname,email);
    }

    @Override
    public ArrayList<VirtualUser> getAllusers() {
        return userDao.getAllusers();
    }

    @Override
    public void updateUser(VirtualUser user) {
        userDao.updateUser(user);
    }

    @Override
    public void deleteUser(int uid) {
        userDao.deleteUser(uid);
    }

    @Override
    public ArrayList<VirtualFile> getUploadHistoryByUid(int uid) {
        return userDao.getUploadHistroyByUid(uid);
    }

}
